package com.blb.educourseservice.controller;


import com.blb.common.entity.CourseOrientation;
import com.blb.common.util.ResponseResult;
import com.blb.educourseservice.service.CourseOrientationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class CourseOrientationController {

    @Autowired
    private CourseOrientationService courseOrientationService;

    @RequestMapping("/course-orientations")
    public ResponseResult<List<CourseOrientation>> getAllCourseOrientations(){
        List<CourseOrientation> list = courseOrientationService.findTopOrientations();
        return ResponseResult.ok(list);
    }

    @RequestMapping("/course-orientations/parent/{parentId}")
    public ResponseResult<List<CourseOrientation>> findOrientationsByParentId(@PathVariable("parentId") Long parentId) {
        List<CourseOrientation> list = courseOrientationService.findOrientationsByParentId(parentId);
        return ResponseResult.ok(list);
    }
}
